#include <iostream>
#include <vector>


long long n;


int main()
{
	while (std::cin >> n) {
		std::vector<long long> a(3*n);
		for (long long i = 0; i <= n; i++) a[i] = n;
		for (long long i = 1; i <= n-1; i++) {
			long long x, y;
			char ch;
			std::cin >> x >> ch >> y;
			if (ch == '*') {
				a[n + i] = a[x] * a[y];
			} else
			if (ch == '/') {
				a[n + i] = a[x] / a[y];
				if (a[x] % a[y]) std::cout << "!!!!!!!!!!!!!fuck!!!!!!!!!!\n";
			} else
			if (ch == '+') {
				a[n + i] = a[x] + a[y];
			} else
			if (ch == '-') {
				a[n + i] = a[x] - a[y];
			}
			if (a[n + i] > 1000000000) std::cout << "!!!!!!!!fuck!!!\n";
		}
		std::cout << n << ": ";
		if (a[2*n-1] == 24) std::cout << "YES\n";
		else std::cout << "NO\n";
	}
}
